home *** CD-ROM | disk | FTP | other *** search
- // BDE32 3.x - (C) Copyright 1996 by Borland International
-
- // initeng.c
- #include "snipit.h"
-
- //========================================================================
- // Function:
- // InitEngSample();
- //
- // Description:
- // This code snippet will initialize IDAPI with a NULL
- // environment structure, connect to a Standard database (used by
- // Paradox and dBASE tables), then clean up before returning.
- // Initializing IDAPI with a NULL environment structure will
- // force IDAPI to scan for the needed CFG file. The search
- // will follow this search hierarchy:
- // 1. Use the CFG specified in the DBIEnv structure (not
- // supplied by this example.
- // 2. Check for a defined CFG file in the WIN.INI file located in
- // your Windows directory. The entry checked for is "[IDAPI]"
- // with an sub-entry of "CONFIGFILE01."
- // 3. Check for the CFG file in the startup directory.
- // 4. When all else fails, IDAPI will initialize with a
- // predefined set of configuration settings. The default
- // settings include no locking of Paradox or dBASE tables,
- // no network access to tables, and no SQL databases.
- //========================================================================
- void
- InitEngSample (void)
- {
- hDBIDb hDb = 0; // Handle to the database
- DBIResult rslt;
-
- Screen("*** Initializing IDAPI ***\r\n");
-
- BREAK_IN_DEBUGGER();
-
- Screen(" Initializing IDAPI...");
-
- rslt = DbiInit(NULL);
- if (ChkRslt(rslt, "Init") == DBIERR_NONE)
- {
- // IDAPI initialized. Now open a Standard database (used to
- // access Paradox, dBASE, and Text tables), by using a NULL
- // database type.
- Screen(" Opening a Standard database...");
-
- rslt = DbiOpenDatabase(NULL, NULL, dbiREADWRITE, dbiOPENSHARED,
- NULL, 0, NULL, NULL, &hDb);
- if (ChkRslt(rslt, "OpenDatabase") == DBIERR_NONE)
- {
- // Database was opened. Go ahead and close it!
- Screen(" Closing the database...");
- rslt = DbiCloseDatabase(&hDb);
- ChkRslt(rslt, "DbClose");
- }
-
- Screen(" Exiting IDAPI...");
- rslt = DbiExit();
- ChkRslt(rslt, "Exit");
- }
- else
- {
- Screen(" Error - Could not initialize IDAPI");
- }
-
- Screen("\r\n*** End of Example ***");
- }
-